<?php
require '../data/data.php';

session_start();
//传送数据
if (isset($_GET['id'])) {
	$id = $_GET['id'];
	//查询要删除的用户记录
	$sql = 'select user_name from `messages` where id = ?';
	$userName = query($sql, [$id])[0];
	$user = $_SESSION['user'];
	if ($userName['user_name'] === $user['user_name']) {
		$sql = 'delete from `messages` where id = ?';
		execute($sql, [$id]);
	}
	header('Location:../../public/index.php');
}
